/*------------------------------------------------------------------------
 *  Copyright (C) 2011  Luis M. de la Cruz
 *
 *  This file is part of TUNA
 *
 *  TUNA is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  TUNA is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ------------------------------------------------------------------------*/

/*!
 ***************************************************************************
 *  \file Tuna.hpp
 *  Types and structures to be used inside of TUNA.
 ***************************************************************************
 *  \author  Luis M. de la Cruz Salas [ Mon Dec 24 14:57:09 GMT 2010 ]
 ***************************************************************************
 *
 * This file contains the main definitions of types and structures used 
 * along the classes and functions of TUNA programs. This file is included
 * in almost all the components of TUNA.
 */

#ifndef _TUNA_H_
#define _TUNA_H_

#include <ctime>
#include <cmath>
#include <iostream>
#include <blitz/array.h>

using namespace blitz;

namespace Tuna {

int BANDERA;
  
const double PI = 4 * atan(1.0);

template<typename T>
struct Typeinfo { };

/*!
 ***************************************************************************
 * \c tiny used mainly for extents and deltas of meshes 
 * (blitz-TinyVector based) and \c huge used for general containers, 
 * scalar fields (blitz-Array based).
 ***************************************************************************
 */
template<typename Tprec, int Dim>
struct TunaArray 
{ 
  /*! Definition of very small arrays. 
   *  This is only a re-definition of tiny arrays from Blitz++ library.
   *  \param Tprec is the precision of the stored numbers.
   *  \param Dim can be 1, 2 or 3. 
   */
  typedef TinyVector<Tprec, Dim> tiny;

  /*! Definition of big arrays to store scalar fields on meshes.
   *  This is only a re-definition of \c Array<> from Blitz++ library.
   *  \param Tprec is the precision of the stored numbers.   
   *  \param Dim can be 1, 2 or 3.
   */
  typedef Array<Tprec, Dim> huge;
};

/*! 
 *  Enumeration for using X, Y and Z as axis names. 
 */
enum Axis_t { X = 0, Y = 1, Z = 2 };

/*! 
 *  Enumeration for using TOP_WALL, etc, as names of boundary walls for
 *  rectangular domains (1D, 2D and 3D), and to impose boundary conditions.
 */
enum BC_t { TOP_WALL  , BOTTOM_WALL,
	    LEFT_WALL , RIGHT_WALL,
	    FRONT_WALL, BACK_WALL };

/*!
 *  Three different norms.
 */
enum Norm { L1, L2, Lmax };
  
  
/*!
 *  Struct useful to measure the elapsed time.
 */
  struct timer
  {

    /*! Start the clock. */
    void tic() 
    { _time = std::clock(); } 
     
    /*! Stop the clock and returns the elapsed time. */
    double toc() const 
    { return double(std::clock() - _time)/CLOCKS_PER_SEC; }

    std::clock_t _time;
  };

/*! 
 *  Enumeration to indentify the neighbors in Cart Comm.
 */
  enum cartDir_t { RIGHT = 0, LEFT = 1, 
		   UP = 2, DOWN = 3, 
		   FRONT = 4, BACK = 5 }; // Neighbors in Cart


} // namespace Tuna

#endif //_TUNA_H_




